#ifndef LASER_H
#define LASER_H

#include "drawable.h"
#include "updateable.h"
#include "spawnable.h"

#include "component.h"

#include "laserBeam.h"

class Laser : public Drawable, public Updateable, public Spawnable, public Component {
    private: 
    bool on;

	cpVect vel_;
	cpVect pos_;
	float  dir_;
	cpVect dirVect_;

	cpVect firingOffset;

    float r;
    float g;
    float b;
	
	cpVect * vertii_;
	int numVertii_;
	
	float baR;
	float baG;
	float baB;
	float baA;
	
	float bbR;
	float bbG;
	float bbB;
	float bbA;
	
	cpVect * blastVertii_;
	int numBlastVertii_;

	Laser(cpBody* host) : Drawable(2), Component(host) {}
    
    public:
	Laser(cpBody* host, cpVect bulletSpeed, cpVect pos, cpVect dir) : Drawable(2), Component(host) {
        on = false;
        vel_ = bulletSpeed;
		pos_ = pos;
		dir_ = -cpvtoangle(cpvnormalize(dir));
		dirVect_ = cpvforangle(dir_);
	
		firingOffset = cpv(0.0, 8.0);

		numVertii_ = 4;
		vertii_ = new cpVect[numVertii_];
		vertii_[0].x =  0.5; vertii_[0].y = 4.0;
		vertii_[1].x =  0.5; vertii_[1].y = 0.0;
		vertii_[2].x = -0.5; vertii_[2].y = 0.0;
		vertii_[3].x = -0.5; vertii_[3].y = 4.0;

		r = 0.5;
        g = 0.5;
        b = 0.5;
		
		numBlastVertii_ = 7;
		blastVertii_ = new cpVect[numBlastVertii_];
		blastVertii_[0].x =  -0.5; blastVertii_[0].y =  4.0;
		blastVertii_[1].x =  -3.0; blastVertii_[1].y =  5.0;
		blastVertii_[2].x = -1.25; blastVertii_[2].y =  6.0;
		blastVertii_[3].x =   0.0; blastVertii_[3].y = 12.0;
		blastVertii_[4].x =  1.25; blastVertii_[4].y =  6.0;
		blastVertii_[5].x =   3.0; blastVertii_[5].y =  5.0;
		blastVertii_[6].x =   0.5; blastVertii_[6].y =  4.0;
		
		baR = 1.0;
    	baG = 0.0;
    	baB = 0.0;
    	baA = 1.0;
    	
    	bbR = 1.0;
    	bbG = 0.0;
    	bbB = 0.0;
    	bbA = 0.25;
    }
    
    void draw();

    void update(float step);

	inline void activate() {on = true;}
	inline void deactivate() {on = false;}
};

#endif
